import humans.QuackCounter;

import java.util.ArrayList;

import semiduck.DuckCall;
import semiduck.goose.Goose;
import semiduck.goose.GooseAdapter;

import duck.Flock;
import duck.Quackable;
import duck.factory.DuckFactory;
import duck.factory.ObservableCounterableDuckFactory;

public class Simulation {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Simulation simulation = new Simulation();
		simulation.simulate();
	}
	
	private ArrayList<Quackable> simulated = new ArrayList<Quackable>();
	private QuackCounter counter;
	private DuckFactory factory;
	
	
	public void simulate() {
			// TODO Auto-generated method stub
			
		counter = QuackCounter.getInstance(); 
		factory = new ObservableCounterableDuckFactory();
		createInstances();		
		for (Quackable d : simulated) {
			d.quack();
		}
		result();
	}

	private void result() {
		System.out.println("Simulation > Quack counter counted "+counter.getCount()+" quack");
	}

	private void createInstances() {
		add(new DuckCall());
		add(new GooseAdapter(new Goose()));
		
		add(factory.getRedhead());
		add(factory.getRubber());
		
		Flock flock = new Flock();
		for(int i=0; i<4; i++) flock.add(factory.getMallard());
		add(flock);
	}
	
	private void add(Quackable q) {
		this.simulated.add(q);
	}

}
